package cn.tedu.sp03.controller;

import cn.tedu.pojo.User;
import cn.tedu.service.UserService;
import cn.tedu.web.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService UserService;
    //获取用户
    @GetMapping("/{userId}")
    public JsonResult<User> getUser(@PathVariable Integer userId){
        User user = UserService.getUser(userId);
        return JsonResult.build().code(200).data(user);
    }
    //增加积分
    //http://localhost:8081/8/score?score=1000
    @GetMapping("/{userID}/score")
    public JsonResult<?> addScore(@PathVariable Integer userID,Integer Score){
        UserService.addScore(userID, Score);
        return JsonResult.build().code(200).msg("增加积分成功");
    }
        @GetMapping("/favicon.ico")
    public  void  ico(){}
}
